package com.ruoyi.web.controller.memberCoupon;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TablePassCardRuleOperations;
import com.ruoyi.system.service.ITablePassCardRuleOperationsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 桌台次卡规则操作日志 Controller
 *
 * @author ruoyi
 * @date 2025-05-23
 */
@Api(tags="桌台次卡规则操作日志")
@RestController
@RequestMapping("/system/tablePassCardRuleOperations")
public class TablePassCardRuleOperationsController extends BaseController
{
    @Autowired
    private ITablePassCardRuleOperationsService tablePassCardRuleOperationsService;

    /**
     * 通过条件查询桌台次卡规则操作日志列表
     */
    @ApiOperation("通过条件查询桌台次卡规则操作日志列表")
    @PreAuthorize("@ss.hasPermi('system:operations:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String operatedStoreCode, @RequestParam(required = false) String operationType, @RequestParam(required = false) String passCardCode, @RequestParam(required = false) Date operationStartTime, @RequestParam(required = false)  Date operationEndTime)
    {
        startPage();
        List<TablePassCardRuleOperations> list = tablePassCardRuleOperationsService.selectTablePassCardRuleOperationsList(operatedStoreCode,operationType,passCardCode,operationStartTime,operationEndTime);
        return getDataTable(list);
    }

    /**
     * 导出桌台次卡规则操作日志列表
     */
    @ApiOperation("导出桌台次卡规则操作日志列表")
    @PreAuthorize("@ss.hasPermi('system:operations:export')")
    @Log(title = "桌台次卡规则操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam(required = false) String operatedStoreCode, @RequestParam(required = false) String operationType, @RequestParam(required = false) String passCardCode, @RequestParam(required = false) Date operationStartTime, @RequestParam(required = false)  Date operationEndTime)
    {
        List<TablePassCardRuleOperations> list = tablePassCardRuleOperationsService.selectTablePassCardRuleOperationsList(operatedStoreCode,operationType,passCardCode,operationStartTime,operationEndTime);
        ExcelUtil<TablePassCardRuleOperations> util = new ExcelUtil<TablePassCardRuleOperations>(TablePassCardRuleOperations.class);
        util.exportExcel(response, list, "【审计】桌台次卡规则操作日志（记录所有门店次卡规则的变更历史）数据");
    }

    /**
     * 通过id获取桌台次卡规则操作日志详细信息
     */
    @ApiOperation("通过id获取桌台次卡规则日志详细信息")
    @PreAuthorize("@ss.hasPermi('system:operations:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tablePassCardRuleOperationsService.selectTablePassCardRuleOperationsById(id));
    }

    /**
     * 新增桌台次卡规则操作日志
     */
    @ApiOperation("新增桌台次卡规则操作日志")
    @PreAuthorize("@ss.hasPermi('system:operations:add')")
    @Log(title = "桌台次卡规则操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TablePassCardRuleOperations tablePassCardRuleOperations)
    {
        return toAjax(tablePassCardRuleOperationsService.insertTablePassCardRuleOperations(tablePassCardRuleOperations));
    }

    /**
     * 修改桌台次卡规则操作日志
     */
    @ApiOperation("修改桌台次卡规则操作日志")
    @PreAuthorize("@ss.hasPermi('system:operations:edit')")
    @Log(title = "桌台次卡规则操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TablePassCardRuleOperations tablePassCardRuleOperations)
    {
        return toAjax(tablePassCardRuleOperationsService.updateTablePassCardRuleOperations(tablePassCardRuleOperations));
    }

    /**
     * 删除桌台次卡规则操作日志
     */
    @ApiOperation("删除桌台次卡规则操作日志")
    @PreAuthorize("@ss.hasPermi('system:operations:remove')")
    @Log(title = "桌台次卡规则操作日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tablePassCardRuleOperationsService.deleteTablePassCardRuleOperationsByIds(ids));
    }
}
